import moment from "moment";

export function dateFormat(date, {format = 'YYYY-MM-DD HH:mm:ss'} = {}) {
    if (!date) {
        return '';
    }
    if (typeof date === 'number') {
        return moment(new Date(date)).format(format);
    } else {
        return moment(date).format(format);
    }
}

export function comfortTime(date) {
    if (!date) {
        return '';
    }
    if (typeof date === 'number') {
        return moment(date)
            .startOf("min")
            .fromNow();
    } else {
        return moment(date.getTime())
            .startOf("min")
            .fromNow();
    }

}